package com.lanhu.designpattern.factory.simplefactory;

/**
 * author:zhangzg
 * date:2020/10/28 21:36
 * 产品工厂类
 */
public class PhoneFacotry {

    public static Phone getPhone(String brand){
        Phone phone = null;

        switch (brand){
            case "apple" :
                phone = new ApplePhone();
                break;
            case "xiaomi" :
                phone = new XiaoMiPhone();
                break;
            case "huawei" :
                phone = new HuWeiPhone();
                break;
             default:
                 throw new IllegalArgumentException("参数错误");
        }
        return phone;
    }
}
